{% extends "admin/base.html" %}
{% block title %}-成绩管理{% endblock %}
{% block grade %}current-item{% endblock %}
{% block mainbody %}

<div class="main">
			<center>
				<h1>添加成绩</h1>
				<span id="error" class="error">{{ error }}</span>
				<form id="insert-form" method="post" action="/admin/insertgrade">
					<table class="table-adduser">
						<tr>
							<td>
								<span>user_id:</span>
							</td>
							<th>
								<input type="text" id="user_id" name="user_id">
							</th>
						</tr>
						<tr>
							<td>
								<span>grade:</span>
							</td>
							<th>
								<input type="text" id="grade" name="grade">
							</th>
						</tr>
					</table>
					<input type="button" id="submit_btn" value="提交">
				</form>

			</center>
		</div>

		<script src="/public/js/common/jquery-1.12.4.min.js"></script>
		<script>
			$(document).keydown(function(event) {
				if(event.keyCode == 13) {
					submitForm()
				}
			});

			$("#submit_btn").click(function() {
				submitForm()
			})

            function  submitForm() {
                if (checkForm()) {
                    $("#error").html("正在提交...");
                    $("#insert-form").submit();
                }
            }

            function checkForm() {
                console.log($("#user_phone").val())
                $("#error").html("");
                if($("#user_id").val().trim() == '') {
					$("#error").html("请输入id");
                    return false;
				}
				if($("#grade").val().trim() == '') {
					$("#error").html("请输入grade");
                    return false;
				}
				return true;
            }

			$("#user_id").blur(function() {
				checkForm()
			})

			$("#grade").blur(function() {
				checkForm()
			})

		</script>

{% endblock %}